package com.zw.xxh.udp;

import com.zw.xxh.rtp.DataPacket;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;

import java.util.List;

public class DataPackageDecoder extends MessageToMessageDecoder<ByteBuf> {

    @Override
    protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List list) throws Exception {
        if (byteBuf.readableBytes() < 12) {
            return;
        }
        DataPacket packet = DataPacket.decode(byteBuf);
        list.add(packet);
    }
}
